package com.xiaochong.bitong.job.schedule;

import com.xc.logclient.utils.LogTrace;
import com.xiaochong.bitong.job.config.ExecutorConfig;
import com.xiaochong.bitong.job.service.CoinAndPairSearchService;
import com.xiaochong.tir.common.data.mapper.ExchangeInfoMapper;
import com.xiaochong.tir.common.data.po.ExchangeInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore;

/**
 * @Description: 货币和交易对搜索定时任务
 * @Author: org
 * @CreateDate: 2018/8/14 16:38
 */
@Component
public class CoinAndPairSearchScheduled {

    @Autowired
    private CoinAndPairSearchService coinAndPairSearchService;

    @Async(ExecutorConfig.SCHEDULER_EXECUTOR_POOL)
    @Scheduled(cron="0 0/5 * * * ?")
    public void calculatePairSort() throws Exception {
        LogTrace.beginTrace();
        long start = System.currentTimeMillis();
        LogTrace.info("thread-交易对搜索定时存入redis数据start","start",String.valueOf(start));
        coinAndPairSearchService.calculatePairSort();
        LogTrace.info("thread-交易对搜索定时存入redis数据end","end",String.valueOf(System.currentTimeMillis()-start));
    }
    @Async(ExecutorConfig.SCHEDULER_EXECUTOR_POOL)
    @Scheduled(cron="0 0/4 * * * ?")
    public void calculateCoinSort() throws Exception {
        LogTrace.beginTrace();
        long start = System.currentTimeMillis();
        LogTrace.info("thread-货币搜索定时存入redis数据start","start",String.valueOf(start));
        coinAndPairSearchService.calculateCoinSort();
        LogTrace.info("thread-货币搜索定时存入redis数据end","end",String.valueOf(System.currentTimeMillis()-start));
    }
}
